package cn.zcx;

import java.util.concurrent.TimeUnit;

/**
 * description:
 * author:zcx
 * lenovo
 * 时间：2022.02.07.16.11
 */
public class T22 {
    //static boolean f=false;
    public static volatile boolean f = false;
    public static void main(String[] args) {
        new Thread(()->{
            String tn=Thread.currentThread().getName();
            System.out.println(tn+"线程启动中....");
            while ((!f)) {
                try {
                    TimeUnit.SECONDS.sleep(2);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
            System.out.println(tn+"线程结束");
        },"worker").start();
        try {
            TimeUnit.SECONDS.sleep(5);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        f=true;
    }
}
